package jp.sourceforge.akjrcp.image.trimming;

import org.eclipse.draw2d.Border;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.SimpleLoweredBorder;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.swt.graphics.Color;

public class SelectAreaFigure extends Figure implements ResizableFigure{
public static  boolean ENABLE_PAINT=true;
	private int lineWidth=1;
	private Color lineColor=new Color(null,255,0,0);
	private int minWidth=24;
	private int minHeight=24;
	private int boxSize=24;
public SelectAreaFigure(){
	//Border border= new SimpleLoweredBorder();
	//this.setBorder(border);
	
}
protected void paintBorder(Graphics graphics) {
	if(ENABLE_PAINT){
	super.paintBorder(graphics);
	}
}

public void paintFigure(Graphics graphics) {
	if(ENABLE_PAINT){
	graphics.setForegroundColor(lineColor);
	graphics.setLineWidth(lineWidth);
	//graphics.setLineDash(new int[]{0,1});

	graphics.drawRectangle(getClientArea().x,getClientArea().y,getClientArea().width-1,getClientArea().height-1);	
	graphics.drawRectangle(getClientArea().x+getClientArea().width-boxSize,getClientArea().y+getClientArea().height-boxSize,boxSize-1,boxSize-1);	
	
	}
}
public boolean isResizeBox(Point point) {
	// TODO Auto-generated method stub
	return point.x>this.getLocation().x+this.getSize().width-boxSize && point.y>this.getLocation().y+this.getSize().height-boxSize;
	
}
public void resize(int incrementWidth, int incrementHeight) {
	int w=Math.max(minWidth, this.getSize().width+incrementWidth);
	int h=Math.max(minHeight, this.getSize().height+incrementHeight);
	this.setSize(w,h);
}

}
